import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import type { App } from 'vue'
//NProgress 插件显示页面加载进度条
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: () => import('@/views/Home.vue'),
  },
]

export const router = createRouter({
  history: createWebHistory(),
  routes,
})

// 配置路由
export const setupRouter = (app: App<Element>) => {
  app.use(router);
}

router.beforeEach(() => {
  NProgress.start();
});

router.afterEach(() => {
  NProgress.done();
});